<script type="text/javascript">
if (getCookie('is_show_extension_tip')) {
	UM_LAYER.open('extension/default');
	setCookie('is_show_extension_tip', '', -1);
}
var home = new function () {
	// recommend -----------------------------
	this.recommend_ob 	= null;
	this.recommend = function (p) {
		loadMod('index/recommend/1w', {'page':p}, this.recommend_ob);
	}
	this.recommend_is_read = function (id) {
		$('#recommend_article_'+id).addClass('is_read');
	}
	// feed -----------------------------------------------------------------------------
	this.feed_ob	= null;
	this.feed_p		= 1;
	this.feed_stop	= false;
	this.feed_lock	= false;
	this.feed = function () {
		if (this.feed_stop == false && this.feed_lock == false) {
			var offset = this.feed_ob.offset();
			if ( (this.feed_ob.height() + offset.top) <  ($(window).height() + $(window).scrollTop()) ) {
				this.feed_lock = true;
				this.feed_ob.append('<div class="loading_will_remove loading_feed">Loading...</div>');
				loadMod('index/feed/1w', {'page':this.feed_p}, this.feed_ob, function (m) {
					$('.loading_feed').remove();
					home.feed_lock = false;
					if (m.substr(0,17) == decodeURI('%3C!--%20mark%20for%20OK,')) {
						home.feed_p++;
						home.feed();
					} else {
						home.feed_stop = true;
					}
				}, 'append');
			} else {
				this.feed_lock = false;
			}
		}
	}
	// circle ---------------------------------------------------------------------------
	this.circle_ob_title		= null;
	this.circle_ob_content	= null;
	this.circle_id		= 0;
	this.circle_page		= 1;
	this.circle_lock		= false;
	this.circle_stop		= false;
	
	this.circle = function (c, o) {
		if (typeof(c) != 'undefined') {
			this.circle_id = c;
		}
		if (typeof(o) == 'object') {
			$(o).parent().children().removeClass('current');
			$(o).addClass('current');
		}
		this.circle_ob_title.html('&nbsp');
		loadMod('index/tee_title', {'circle_id':this.circle_id}, this.circle_ob_title, function(){
			home.circle_page		= 1;
			home.circle_stop		= false;
			home.circle_ob_content.html('');
			home.circle_content();
		} );
	}
	this.circle_content = function () {
		if (this.circle_lock == false && this.circle_stop == false) {
			this.circle_lock = true;
			this.circle_ob_content.append('<div class="loading_will_remove loading_tee">Loading...</div>');
			loadMod('index/tee_content', {'circle_id':this.circle_id, 'page':this.circle_page}, this.circle_ob_content, function(m) {
				$('.loading_tee').remove();
				if (home.circle_page == 1) {
					$('html,body').animate({scrollTop:0},500);
				}
				if (m.substr(0,17) == decodeURI('%3C!--%20mark%20for%20OK,')) {
					home.circle_stop = false;
				} else {
					home.circle_stop = true;
				}
				home.circle_lock = false;
				home.circle_page ++;
			}, 'append' );
		}
	}
	this.circle_set_page = function (p) {
		this.circle_page = p;
		this.circle_ob_content.html('');
		$('html,body').animate({scrollTop:0},500);
		this.circle_stop = false;
		this.circle_content();
	}
}
$(window).scroll(function(){
	home.feed();
	if ( ($(document).height() - $(window).height() - $(window).scrollTop()) < 20 ) {
		home.circle_content();
	}
});
</script>
    
<table id="index_main_table" width=100% cellpadding=0 cellspacing=0>
	<tr valign=top>
		<td class="col_left circle_menu">
			<{if $circles}>
				<{section name=i loop=$circles}>
					<div class="item" onclick="home.circle(<{$circles[i].id}>, this);" onmouseover="$(this).addClass('hover');" onmouseout="$(this).removeClass('hover');">
						<table width=100% cellpadding=0 cellspacing=0 border=0>
							<tr valign="middle">
								<td width="16">
									<{if $circles[i].member_type == "founder"}>
										<i class="i16_admin"></i>
									<{elseif $circles[i].member_type == "admin"}>
										<i class="i16_admin"></i>
									<{elseif $circles[i].member_type == "member"}>
										<i class="i16_member"></i>
									<{elseif $circles[i].member_type == "follower"}>
										<i class="i16_follower"></i>
									<{/if}>
								</td>
								<td><a class="title <{if $circles[i].privacy == 'private'}>private<{/if}> "><{$circles[i].title}></a></td>
							</tr>
						</table>
						<table class="info" width=100% cellpadding=0 cellspacing=0>
							<tr>
								<td width=33%><a class="link">成员：<{$circles[i].total_member}></a></td>
								<td width=33%><a class="link">订阅：<{$circles[i].total_follower}></a></td>
								<td width=34%><a class="link">文章：<{$circles[i].total_article}></a></td>
							</tr>
						</table>
					</div>
				<{/section}>
				<div class="item" style="text-align:right; color:#777;">
					<a style="color:#369;" onclick="UM_LAYER.open('circle/show_add', '', this);">+创建阅读圈</a>
					<span style="color:#777; margin:0 5px;">|</span> 
					<a style="color:#369;" href="/hot.php">查看热门阅读圈</a>
				</div>
			<{else}>
				<div class="item">
					您还没有加入或者订阅阅读圈，您可以：
					<ul>
						<li><a style="font-size:16px;" href="/hot.php">查看热门阅读圈</a></li>
						<div style="padding-left:20px; line-height: 200%; padding-bottom:20px;">发现兴趣相投的圈子，添加订阅；</div>
					</ul>
				</div>
			<{/if}>
		</td>
		<td class="col_center">
			<!-- recommend Start ############################################################################################################ -->
			<div id="index_recommend">
				<script type="text/javascript">
					home.recommend_ob = $('#index_recommend');
					home.recommend(1);
				</script>
			</div>
			<!-- recommend End ############################################################################################################ -->

			<div xid="index_circle" id="circle_article_list" class="article_list">
				<div class="hd" id="circle_article_title">
				</div>
				<div id="circle_article_content">
				</div>
				<script type="text/javascript">
					home.circle_ob_title 	= $('#circle_article_title');
					home.circle_ob_content	= $('#circle_article_content');
					home.circle(0);
				</script>
			</div>
		</td>
		<td class="col_right">
			<!-- Feed Start ############################################################################################################ -->
			<div class="rblock">
				<div class="hd">
					<div class="more">
					</div>
					<i class="icon_y icon_triangle_down"></i>
					<a>好友动态</a>
				</div>
				<div id="index_feed">
					<script type="text/javascript">
						home.feed_ob = $('#index_feed');
						home.feed();
					</script>
				</div>
			</div>
			<!-- Feed End ############################################################################################################ -->
		
		</td>
	</tr>
</table>

<script type="text/javascript">
	var ureadmer = getCookie('ureadmer');
	if (ureadmer) {
		setCookie('ureadmer', '', -1);
	}
	<{if $recommend_info}>
		// popup recommend reader
		open_reader('<{$recommend_info.id}>', '<{$recommend_info.open_type}>', function(){ home.recommend_is_read('<{$recommend_info.id}>'); });
	<{/if}>
</script>
